//
//  UIView+OYCategory.m
//  name
//
//  Created by 欧阳芳斌 on 2017/6/20.
//  Copyright © 2017年 zhangyou. All rights reserved.
//

#import "UIView+OYCategory.h"

@implementation UIView (OYCategory)

- (CGSize)oy_size {
    
    return self.frame.size;
}

- (void)setOy_size:(CGSize)oy_size {
    
    CGRect frame = self.frame;
    frame.size = oy_size;
    self.frame = frame;
}

- (CGFloat)oy_width {
    
    return self.frame.size.width;
}

- (void)setOy_width:(CGFloat)oy_width {
    
    CGRect frame = self.frame;
    frame.size.width = oy_width;
    self.frame = frame;
}

- (CGFloat)oy_height {
    
    return  self.frame.size.height;
}

- (void)setOy_height:(CGFloat)oy_height {
    
    CGRect frame = self.frame;
    frame.size.height = oy_height;
    self.frame = frame;
}

- (CGFloat)oy_x {
    
    return self.frame.origin.x;
}

- (void)setOy_x:(CGFloat)oy_x {
    
    CGRect frame = self.frame;
    frame.origin.x = oy_x;
    self.frame = frame;
}

- (CGFloat)oy_y {
    
    return self.frame.origin.y;
}

- (void)setOy_y:(CGFloat)oy_y {
    
    CGRect frame = self.frame;
    frame.origin.y = oy_y;
    self.frame = frame;
}

- (CGFloat)oy_centerX {
    
    return self.center.x;
}

- (void)setOy_centerX:(CGFloat)oy_centerX {
    
    CGPoint center = self.center;
    center.x = oy_centerX;
    self.center = center;
}

- (CGFloat)oy_centerY {
    
    return self.center.y;
}

- (void)setOy_centerY:(CGFloat)oy_centerY {
    
    CGPoint center = self.center;
    center.y = oy_centerY;
    self.center = center;
}

- (CGFloat)oy_right {
    
    //    return self.oy_x + self.oy_width;
    return CGRectGetMaxX(self.frame);
}

- (CGFloat)oy_bottom {
    
    //    return self.oy_y + self.oy_height;
    return CGRectGetMaxY(self.frame);
}

- (void)setOy_right:(CGFloat)oy_right {
    
    self.oy_x = oy_right - self.oy_width;
}

- (void)setOy_bottom:(CGFloat)oy_bottom {
    
    self.oy_y = oy_bottom - self.oy_height;
}

- (UITapGestureRecognizer *)oy_addTarget:(id)target action:(SEL)action {
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:target action:action];
    self.userInteractionEnabled = YES;
    [self addGestureRecognizer:tap];
    return tap;
}

- (void)addBorderColor:(UIColor *)color {
    
    [self.layer setBorderColor:color.CGColor];
    [self.layer setBorderWidth:0.5];
    [self.layer setCornerRadius:4];
}


@end
